package com.obligatorio.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllPais", query = "SELECT p FROM Pais p order by p.nombre"),
		@NamedQuery(name = "findPaisByName", query = "SELECT p FROM Pais p WHERE p.nombre =:Nombre") })
public class Pais implements Serializable {

	private final static long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "PaisId")
	private Integer id;

	@Column(name = "PaisNombre", nullable = false)
	private String nombre;

	public Pais() {
	}

	public Pais(Integer id, String nombre) {
		this.id = id;
		this.nombre = nombre;
	}

	public Pais(String str) {
		this.nombre = str;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNombre() {
		return nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	@Override
	public boolean equals(Object object) {
		if (!(object instanceof Pais)) {
			return false;
		}
		Pais other = (Pais) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return getNombre();
	}
}
